Skip to main content

MasterChef

The MasterChef gives out a constant number of SUSHI per block, for liquidity providers that stake SLP tokens within contract.

New ERC20s or pools are added/updated by the owner of the contract with allocation points that determines the number of SUSHI rewarded to each pool.

MasterChef is the only contract with minting rights for the SUSHI token.

The full contract can be found here.

Functions

poolLength

function poolLength(
) external view returns (uint256)

Polls and returns the total number of pools added.

add

function add(
uint256 _allocPoint,
IERC20 _lpToken,
bool _withUpdate
) public onlyOwner

Adds a new SLP/Token to be staked, and can only be called by the owner.

Adding duplicate pools can cause problems with the rewards.

Parameters

NameTypeDescription
_allocPointuint256number of allocation points assigned to pool
_lpTokenIERC20address of ERC20 token that will be staked
_withUpdateboolbool to call massUpdatePools or not

set

function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner

Updates the allocation points assigned to an existing pool, and can only be called by the owner.

Parameters

NameTypeDescription
_piduint256id for individual pool
_allocPointuint256number of allocation points assigned to pool
_withUpdateboolbool to call massUpdatePools or not

setMigrator

function setMigrator(
IMigratorChef _migrator
) public onlyOwner

Sets the contract that is has ability to perform a migration for staked tokens, and can only be called by the owner.

Parameters

NameTypeDescription
_migratorIMigratorChefaddress of migrator contract

migrate

function migrate(
uint256 _pid
) public

Migrates an lp token/pool to another lp contract. Can be called by anyone, and we trust that migrator contract is good.

Parameters

NameTypeDescription
_piduint256id for individual pool

getMultiplier

function getMultiplier(
uint256 _from,
uint256 _to
) public view returns (uint256)

Polls and returns reward multiplier over a given _from to _to block.

Parameters

NameTypeDescription
_fromuint256start block number
_touint256end block number

pendingSushi

function pendingSushi(
uint256 _pid,
address _user
) external view returns (uint256)

Polls and returns pending SUSHIs to be claimed for a given pool and user.

Parameters

NameTypeDescription
_piduint256id for individual pool
_useraddressaddress for user

massUpdatePools

function massUpdatePools(
) public

Updates reward variables for all pools.

updatePool

function updatePool(
uint256 _pid
) public

Update reward variables for a given pool to be kept up-to-date.

Is called on all withdraws, and deposits. So will only be called by itself individually for pools that aren't as active to keep them up-to-date when updating allocation points.

Parameters

NameTypeDescription
_piduint256id for individual pool

deposit

function deposit(
uint256 _pid,
uint256 _amount
) public

Deposit LP tokens to MasterChef to start accruing SUSHI rewards.

Parameters

NameTypeDescription
_piduint256id for individual pool
_amountuint256amount of tokens to deposit

withdraw

function withdraw(
uint256 _pid,
uint256 _amount
) public

Withdraw LP tokens from MasterChef.

Parameters

NameTypeDescription
_piduint256id for individual pool
_amountuint256amount of tokens to withdraw

emergencyWithdraw

function emergencyWithdraw(
uint256 _pid
) public

Withdraw LP tokens from MasterChef without receiving SUSHI rewards. To be only used for emergencies or problems with harvesting rewards.

Parameters

NameTypeDescription
_piduint256id for individual pool

safeSushiTransfer

function safeSushiTransfer(
address _to,
uint256 _amount
) internal

Internal function to be used in case of rounding error that causes pool to not have enough SUSHI.

Parameters

NameTypeDescription
_toaddressaddress to transfer to
_amountuint256amount to transfer